package com.jz.community.moduleshoppingguide.home.ui.activity;

import android.graphics.Bitmap;
import android.view.View;

import com.jz.community.basecomm.base.BaseX5WebActivity;
import com.jz.community.basecomm.bean.ShareInfo;
import com.jz.community.basecomm.utils.RxDataTool;
import com.jz.community.moduleshoppingguide.home.ui.view.ShareBannerPopUp;

public class ShareWebActivity extends BaseX5WebActivity {


    private ShareBannerPopUp shareBannerPopUp;

    @Override
    protected void initView() {
        super.initView();
    }

    @Override
    protected void initDatas() {
        super.initDatas();
    }

    @Override
    public void onBackPressedSupport() {
        super.onBackPressedSupport();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void shareWeb() {
        if (!RxDataTool.isNullString(shareUrl)) {
            ShareInfo shareInfo = new ShareInfo();
            shareInfo.setLink(shareUrl);
            shareInfo.setSubject(shareTitle);
            shareInfo.setText(shareDesc);
            shareInfo.setImageUrl(shareImg);
            showSharePop(shareInfo);
        }
    }

    private void showSharePop(ShareInfo shareInfo) {
        if (shareBannerPopUp == null) {
            shareBannerPopUp = new ShareBannerPopUp(this);
            shareBannerPopUp.addBannerDetailInfo(shareInfo, screenShotView(x5Web));
            shareBannerPopUp.showBannerSharePopUp(webTitle);
        } else {
            shareBannerPopUp.showBannerSharePopUp(webTitle);
        }
    }

    private Bitmap screenShotView(View view) {
        //开启缓存功能
        view.setDrawingCacheEnabled(true);
        //创建缓存
        view.buildDrawingCache();
        //获取缓存Bitmap
        Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
        return bitmap;
    }
}
